/**
 * Created by CAOTE on 12/12/2016.
 */
'use strict';

/**
 * Module dependencies.
 */
//Load Node.js library
var _ = require('lodash');
var path = require('path');
var request = require('request');
var util = require('util');
var domainFacade = require('../facade/domainFacade');

exports.updateDomain = updateDomain;
exports.getDomain = getDomain;
function updateDomain(reg, res, next){
    domainFacade.updateDomain(_.result(reg, 'body'), function(err, result){
        if(err){
            return next(new Error(err))
        }else{
            var response = {};
            response.resultCode = '01';
            response.message = 'Save Information Successfully';
            return res.send(response);
        }
    })
}


function getDomain(req, res, next){
    domainFacade.getDomain(function(err, result){
        if(err){
            console.log("Get Domain failed!");
            return next(new Error(err))
        }else{
            return res.json(result);
        }
    })
}